home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Presentations / Presentations ’88 / Fritz Proceedings stuff / PatchLMgr.a < prev    next >
Text File  |  1988-04-01  |  4KB  |  175 lines

  1. *
  2. *    PatchLMgr.a
  3. *
  4. *    Created    Thursday, March 31, 1988 5:22:58 PM
  5. *
  6.  
  7.     Case    On
  8.     Print    Off
  9.  
  10.     Include    'Traps.a'
  11.     Include    'PackMacs.a'
  12.     Include    'SysEqu.a'
  13.     Include    'ToolEqu.a'
  14.  
  15.     Print    On
  16.     
  17. Pack0Trap    Equ    $A9E7
  18. ScrRctTrap    Equ    $A8EF
  19.     
  20. LUpFrame    Record    {return},decr
  21. theRgn    DS.L    1    ; Region to redraw
  22. lHandle    DS.L    1    ; Handle to the list
  23. selector    DS.W    1    ; MUST BE 100
  24. return    DS.L    1    ; Return address
  25. paramSize    Equ    theRgn - *
  26.     EndR
  27.  
  28. ScRectFrame    Record    {return},decr
  29. r    DS.L    1
  30. dh    DS.W    1
  31. dv    DS.W    1
  32. updateRgn    DS.L    1
  33. return    DS.L    1
  34. paramSize    Equ    r - *
  35.     EndR
  36.  
  37. LUpPatch    Proc    Export
  38.     With    LUpFrame
  39.     
  40.     Cmp.W    #lUpdate, selector(SP)
  41.     Beq.S    DoYourStuff
  42.     Move.L    ApplScratch, A0
  43.     Jmp    (A0)
  44.  
  45. ;    What We Want:
  46. ;
  47. ;    Before            After
  48. ;    ======            =====
  49. ;    Caller's return    (SP)    selector
  50. ;        "    2(SP)    lHandle
  51. ;    selector        4(SP)        "
  52. ;    lHandle        6(SP)    theRgn
  53. ;        "    8(SP)        "
  54. ;    theRgn        10(SP)    lHandle
  55. ;        "    12(SP)        "
  56. ;    Don't care        14(SP)    theRgn
  57. ;        "    16(SP)        "
  58. ;        "    18(SP)    Caller's return
  59. ;        "    20(SP)        "
  60. ;            ETC.
  61. ;    The stack _was_ 14 bytes deep; it is to be 22 bytes deep.
  62.  
  63.  
  64. DoYourStuff    Lea    selector(SP), A0    ; Re-push the arguments:
  65.     Move.L    (SP), D0        ; Keep the return address
  66.     Lea    -8(SP), SP        ; Make room two longs
  67.     Move.L    SP, A1        ; A1 is destination
  68.     Move.W    (A0)+, (A1)+    ; selector
  69.     Move.L    (A0)+, (A1)+    ; lHandle
  70.     Move.L    (A0), (A1)+        ; theRgn
  71.     Lea    2(SP), A0        ; Point to lHandle again.
  72.     Move.L    (A0)+, (A1)+    ; lHandle
  73.     Move.L    (A0), (A1)+        ; theRgn
  74.     Move.L    D0, (A1)        ; return address
  75.  
  76.     Move.L    ApplScratch, A0
  77.     Jsr    (A0)        ; Call the real LUpdate
  78.  
  79.     Import    LUpdatePatch
  80.     Jsr    LUpdatePatch
  81.     Lea    8(SP), SP        ; Remove the arguments
  82.     Rts            ; Return to caller
  83.     
  84.     EndWith
  85.  
  86.     Entry    ScrRctPat
  87. ScrRctPat
  88.     With    ScRectFrame
  89.     Clr.W    -(SP)
  90.     _SetResLoad            ; Don't force a load
  91.     
  92.     Clr.L    -(SP)
  93.     Move.L    #'PACK', -(SP)
  94.     Clr.W    -(SP)
  95.     _GetResource        ; Get handle to PACK 0
  96.     
  97.     Move.L    #1, D0
  98.     Move.B    D0, -(SP)        ; (Previous result still on stk)
  99.     _SetResLoad            ; Enable rsrc loading.
  100.  
  101.     Move.L    (SP)+, D0        ; Examine PACK 0 handle
  102.     Beq.S    @0        ; No business if no resource
  103.     
  104.     Move.L    D0, A1        ; A1 has original handle
  105.     Move.L    (A1), D0        ; Master pointer
  106.     _StripAddress        ; Strip flag bits
  107.     Tst.L    D0        ; Examine Addr(PACK 0)
  108.     Beq.S    @0        ; No business if not loaded
  109.     
  110.     Move.L    (SP), D1        ; caller's address
  111.     Sub.L    D0, D1        ; D1 <- offset of call in PACK
  112.     Blt.S    @0        ; No business if below PACK
  113.     
  114.     Move.L    A1, A0
  115.     _GetHandleSize
  116.     
  117.     Cmp.L    D0, D1        ; Offset > size of PACK?
  118.     Bgt.S    @0        ; Yes.  not interested.
  119.     
  120.     ; By here, we have verified that ScrollRect was called by the
  121.     ; List Manager.
  122.  
  123.     Import    MYSCRRECT
  124.     Lea    MYSCRRECT, A0
  125.     Bra.S    @1        ; Continue with my patch.
  126.  
  127. @0    Move.L    ApplScratch+8, A0    ; Continue with ScrRect
  128. @1    Jmp    (A0)
  129.     
  130.     EndWith
  131.  
  132.     Entry    LUPatOut
  133. LUPatOut    Move.W    #Pack0Trap, D0    ; Pack 0
  134.     Move.L    ApplScratch, A0    ; Restore old address.
  135.     _SetTrapAddress
  136.     
  137.     Move.W    #ScrRctTrap, D0
  138.     Move.L    ApplScratch+8, A0    ; Restore old address.
  139.     _SetTrapAddress
  140.     
  141.     Move.L    ApplScratch+4, IAZNotify
  142.                 ; Get the saved IAZNotify
  143.     Beq.S    @0        ; If NULL, don't call it
  144.     Move.L    IAZNotify, A0
  145.     Jmp    (A0)        ; Jump right to it.
  146.     
  147. @0    Rts
  148.  
  149.     Export    LUPatIn
  150. LUPatIn    Move.W    #Pack0Trap, D0
  151.     _GetTrapAddress
  152.     Move.L    A0, ApplScratch    ; Save the trap addr in ApplScratch
  153.     
  154.     Move.W    #ScrRctTrap, D0
  155.     _GetTrapAddress
  156.     Move.L    A0, ApplScratch+8    ; Save the trap addr in ApplScratch
  157.     
  158.     Move.L    IAZNotify, ApplScratch+4
  159.                 ; Keep the old IAZNotify pointer
  160.     Lea    LUPatOut, A0
  161.     Move.L    A0, IAZNotify    ; Install our trap-removal routine
  162.     
  163.     Lea    LUpPatch, A0
  164.     Move.W    #Pack0Trap, D0
  165.     _SetTrapAddress        ; Install our Pack0
  166.     
  167.     Lea    ScrRctPat, A0
  168.     Move.W    #ScrRctTrap, D0
  169.     _SetTrapAddress        ; Install our ScrollRect
  170.     Rts
  171.     
  172.     EndProc
  173.  
  174.     End
  175.